import { _decorator, Label, Sprite, UITransform } from 'cc';
import { RedDotConfig } from '../Config/RedDotConfig';
import { RedDotType } from '../../Data/Types';
import { NodeRecycle } from '../Manager/PoolManager';
const { ccclass, property, menu } = _decorator;

@ccclass('RedDot')
@menu('myComponent/RedDot')
export class RedDot extends NodeRecycle {
  @property(Sprite)
  dot: Sprite;
  @property(Label)
  lab: Label;

  setRedDotData(val: number, type: RedDotType) {
    const resultText = RedDotConfig.GetRedDotResultText(val, type);
    this.lab.string = resultText;
    this.node.active = val > 0;
  }

  setRedDotSize(val: number) {
    const form = this.node.getComponent(UITransform);
    form.width = val;
    form.height = val;
  }
}
